/*
	@file : detail/OStreamLoggerScope.cpp
	@author : Wolfhead
*/
#include "detail/OStreamLoggerScope.h"
#include "Log.h"

namespace logger
{

OStreamLoggerScope::OStreamLoggerScope(
	LogPriority pri, 
	std::ostream& os,
	const std::string& logger_name /*= "scope_logger"*/,
	const std::string& format /*= "[%D][%P] %M (%F:%L)(%f)"*/)
	: m_logger_name(logger_name)
{
	LogOption option;
	option.priority = pri;
	option.logger_ptr = LoggerPtr(new logger::OStreamLogger(os));
	option.formatter_ptr = 
		FormatterPtr(new StringFormatter(format));
	option.start_on_create = true;
	option.queue_timeout = 1;
	option.force_notify_priority = kAll;

	get_log_dispatcher().add(logger_name, option);
}

OStreamLoggerScope::~OStreamLoggerScope()
{
	get_log_dispatcher().remove(m_logger_name);
}

}//namespace logger
